import util.StudentDBUtil;
import org.junit.Test;
import pojo.Student;
import vo.StudentVO;

import java.util.ArrayList;
import java.util.List;

public class StundentTest {
    public static void main(String[] args)  {
        StudentDBUtil studentDBUtil = new StudentDBUtil();
        Student stu=new Student(0,"飞飞3","男",23,305,"123");

        studentDBUtil.addStudent2(stu);


    }
    @Test
    public void updateStudent(){
        StudentDBUtil studentDBUtil = new StudentDBUtil();
        Student student = new Student(106, null, "男", 15, 301);
        studentDBUtil.updateStudent(student);
    }

    //查询学生相关信息成绩教师
    @Test
    public void getStudentInfo () {
        StudentDBUtil studentDBUtil = new StudentDBUtil();
        List<StudentVO> stusGradeAndTeacher = studentDBUtil.getStusGradeAndTeacher();
        //lambda 表达式
        stusGradeAndTeacher.stream().forEach(System.out::println);
    }
    //查询学生相关信息成绩教师2
    @Test
    public void getStudentInfo2() {
        StudentDBUtil studentDBUtil = new StudentDBUtil();
        List<Student> stuList = studentDBUtil.getStusGradeAndTeacher2();
        //lambda
        stuList.stream().forEach(System.out::println);
    }

    //查询学生相关信息成绩教师3
    @Test
    public void getStudentInfo3() {
        StudentDBUtil studentDBUtil = new StudentDBUtil();
        List<Student> stuList = studentDBUtil.getStusGradeAndTeacher2();
        List<StudentVO> studentVOList = new ArrayList<>();
        for (Student st : stuList) {
            StudentVO studentVO = new StudentVO(st.getSno(), st.getSname(), st.getSex(), st.getAge(), st.getGrade().getGname(), st.getGrade().getGdesc(), st.getGrade().getTeacher().getTname());
            studentVOList.add(studentVO);
        }
        studentVOList.stream().forEach(System.out::println);
    }
}
